package com.db.springcloud.service;

import com.db.springcloud.pojo.User;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class UserClientServiceFallbackFactory implements FallbackFactory {
    @Override
    public UserClientService create(Throwable cause) {
        return new UserClientService() {
            @Override
            public boolean addUser(User user) {
                return false;
            }

            @Override
            public User queryById(int id) {
                return new User()
                        .setId(id)
                        .setName("没有对应的信息，客户端提供了降级的信息，这个服务现在已经关闭!");
            }

            @Override
            public List<User> queryAll() {
                return null;
            }
        };
    }
}
